﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Practices.Unity;
using Microsoft.Practices.Unity.Configuration;
using System.Configuration;

namespace KandaAlpha.IoC
{
    public static class IoCWorker
    {

        private static IUnityContainer _container;

        /// <summary>
        /// wires up the ioc container
        /// </summary>
        static IoCWorker()
        {
            
        }

        /// <summary>
        /// Returns an injected implementation for the requested interface
        /// </summary>
        public static T Resolve<T>()
        {
            _container = new UnityContainer();
            UnityConfigurationSection section = (UnityConfigurationSection)ConfigurationManager.GetSection("unity");
            section.Containers["containerOne"].Configure(_container);
            return _container.Resolve<T>();
        }

        /// <summary>
        /// Returns an injected implementation for the requested interface
        /// </summary>
        public static object Resolve(Type t)
        {
            _container = new UnityContainer();
            UnityConfigurationSection section = (UnityConfigurationSection)ConfigurationManager.GetSection("unity");
            section.Containers["containerOne"].Configure(_container);
            return _container.Resolve(t);
        }

    }
}
